<!DOCTYPE html>
<html lang="zh-cn">
<head>
{include file="public/header" /}
<script type="text/javascript" src="__HOUTAI__/js/ajaxfileupload.js"></script>
</head>
<body>
<div class="panel admin-panel">
  <div class="body-content">
    <form id="page-form" class="form-x" action="">  
      <input type="hidden" name="id" value="{$page.id}" id="id"><!--ID-->
      <div class="form-group">
        <div class="label">
          <label>标题：</label>
        </div>
        <div class="field">
          <input type="text" class="input w50" value="{$page.title}" name="title" id="titleid" />
          <div class="tips"></div>
        </div>
      </div>
      <div class="form-group">
        <div class="label">
          <label>内容：</label>
        </div>
        <div class="field">
          <!-- 加载编辑器的容器 -->
          <script id="content" name="content" type="text/plain">{$page.content}</script>
          <!-- 配置文件 -->
          <script type="text/javascript" src="__BJQ__ueditor/ueditor.config.js"></script>
          <!-- 编辑器源码文件 -->
          <script type="text/javascript" src="__BJQ__ueditor/ueditor.all.js"></script>
          <!-- 实例化编辑器 -->
          <script type="text/javascript">
            var ue= UE.getEditor('content',{initialFrameWidth:'100%',initialFrameHeight:300,});
          </script>
        </div>
      </div>
      <div class="clear"></div>
      <div class="form-group">
        <div class="label">
          <label></label>
        </div>
        <div class="field">
          <button class="button bg-main icon-feiji" type="submit"> 提交</button>
        </div>
      </div>
    </form>
  </div>
</div>
<script type="text/javascript">
$(function(){
  $('#page-form').validate({
    rules:{
      title:{
        required:true,
      }
    },
    message:{
      title: {
        required: "请输入标题名称",
      }
    },
    onkeyup: false,
    focusCleanup: true,
    success: "valid",
    submitHandler:function(form){
      var title= $("#titleid").val();//标题
      var id= $("#id").val();//标题 
      var content = ue.getContent();//获取富文本内容
      $.ajax({
        type:"POST",
        url:"{:url('danye/pageajax')}",
        data:{
          'id':id,
          'title':title,
          'content':content,
        },
        success:function(data){
          var data=eval("("+data+")");
          if (data.status) {
            parent.layer.msg("文章添加成功！！！",{icon:1,time:1000,},function(){parent.location.reload();});
          }else{
            parent.layer.msg("文章添加失败！！！",{icon:2,time:1000});
          }
        }
      })
    }
  })
})
</script>
</body></html>